<include file="Article:leftmenu" />

    <style>
    

#uploadPic {
	padding:0px 0px 20px 0px;
	height:auto;
}
#uploadPic ul {
	list-style-type:none;
	margin:0px;
	padding:0px;
	border:0;
	float:left;
}
#uploadPic li {
	float:left;
	width:82px;
	height:88px;
	margin:0 5px 5px 0;
	padding-bottom:3px;
	overflow:hidden;
	background:#eee;
	position:relative
}
#uploadPic .displayimg {
	width:76px;
	height:60px;
	border:1px solid #ccc;
	overflow:hidden;
	background:#fff;
	padding:2px;
	text-align:center;
	vertical-align:middle;
}
#uploadPic .displayimg img {
	width:76px;
	height:60px;
}
#uploadPic .previous {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 33px 0 12px;
	margin:7px 33px 0 12px\9;
*margin:7px 33px 0 12px;
	_margin:7px 33px 0 12px;
}
#uploadPic .previous:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -19px;
}
#uploadPic .previous:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat 0 -7px;
}
#uploadPic .next {
	display:inline-block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
	line-height:100px;
	vertical-align:middle;
	overflow:hidden;
	margin:-12px 0 0;
	margin:7px 0 0\9;
*margin:7px 0 0;
	_margin:7px 0 0;
}
#uploadPic .next:hover {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -19px;
}
#uploadPic .next:active {
	background:url(/Static/admin/js/swfupload/img/pre-next-delete.gif) no-repeat -14px -7px;
}
#uploadPic .delete {
	display:block;
	width:13px;
	height:12px;
	background:url(/Static/admin/js/swfupload/img/closeyes.gif) no-repeat 0 0;
	line-height:100px;
	overflow:hidden;
	position:absolute;
	top:3px;
	right:3px;
	z-index:999
}
#uploadPic .delete:hover {
	background:url(/Static/admin/js/swfupload/img/close-hover.gif) no-repeat 0 0;
}
#uploadPic .front-cover {
	position:absolute;
	bottom:5px;
    *bottom:-8px;
	left:30px;
	color:#666
}
#uploadPic div {
	clear:both;
}
#uploadPic input.picDesc {
	width:80px;
*width:78px;
	text-align:center;
	margin:0;
	border:1px solid #7F9DB9;
	margin-top:2px;
	display:none;
}
#uploadPic span.upload_error {
	background-color:#FFD7D7;
	color:#000;
	padding:4px;
	font-family:Tahoma;
	line-height:24px;
}
#upload_tip {
	padding-left:15px;
	height:27px;
	line-height:27px;
}
#upload_tip span {
	color:#F30
}
.purviews {
	padding:10px 300px 10px 10px;
}
.purviews p{
	line-height:18px;
}
.purviews span {
	font-variant:normal;
	display:block;
	float:left;
	width:12%;
}
.jindubox {
	width:500px;
	margin:0 auto;
	height:30px;
	background: #CCC;
}
.jindu {
	color:#FFF;
	font-size:12px;
	font-weight:bolder;
	background:url(/Static/admin/js/swfupload/img/bfbg.gif) left top repeat-x;
	height:30px;
}
    </style>
<script type="text/javascript" src="__STATIC__admin/js/swfupload/swfupload.js" ></script>
<script type="text/javascript" src="__STATIC__admin/js/swfupload/article.js" ></script>




<div class="content-right fl">
    <h1 class="content-right-title">发布文章</h1>
    
<ul class="wizard">
    <li class="wizard-item process">
        <dl class="wizard-item-content">
            <dt class="wizard-ic-step">
                <span class="wizard-icstp-num">1</span>
                <span class="wizard-icstp-title">编辑文章信息</span>
            </dt>
            <dd class="wizard-ic-desc"></dd>
        </dl>
    </li>
    <li class="wizard-item">
        <dl class="wizard-item-content">
            <dt class="wizard-ic-step">
                <span class="wizard-icstp-num">2</span>
                <span class="wizard-icstp-title">编辑文章详情</span>
            </dt>
        </dl>
    </li>

</ul>
<form id="form" aciton="" method="post" id="add" onsubmit="return false">

<div class="panel-single panel-single-light mgt20">
    <h3 class="cst_h3 mgb20">文章信息</h3>
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>文章标题：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" maxlength="25"  name="title" value="<?php echo $article['title'];?>" maxlength="22">
            <span class="fi-help-text">最长22个字</span>
        </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name">是否显示标题栏：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_title" value="1" name="is_title" <?php echo isset($article['is_title']) && ($article['is_title']) ? "checked" : (!isset($article['is_title']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_title" value="0" name="is_title" <?php echo isset($article['is_title']) && (!$article['is_title']) ? "checked" : "";?>>隐藏</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
  
    
    <span id="teacher_tap" <?php if(!$article['author_uid']){ ?> style="display:none;" <?php } ?>   >
    
    
    
    
    </span>
    
    
<!--   
    
    <div class="formitems">
        <label class="fi-name">阅读原文链接：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" maxlength="255" id="more_url" name="more_url" value="<?php echo $article['more_url'];?>">
            <span class="fi-help-text">阅读原文链接,以 http:// 开头</span>
        </div>
    </div>
 -->
    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>文章分类：</label>
        <div class="form-controls">
			<select name="atype_id" class="select small newselect">
				<option value="" selected="">未分类</option>
				<?php foreach($atype as $k=>$v){ ?>
				<option value="<?php echo $v['atype_id'];?>"  <?php echo $v['atype_id']==$article['atype_id']?"selected":"";?>><?php echo $v['atype_name'];?></option>
				<?php } ?>
			</select>
            <span class="fi-help-text">请选择文章分类</span>
        </div>
    </div>

<!-- 
    
    <div class="formitems">
        <label class="fi-name">点赞数：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="vote_nums" value="<?php echo $article['vote_nums'];?>">
            <span class="fi-help-text"></span>
        </div>
    </div>
	
 
    <div class="formitems">
        <label class="fi-name">排序：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="ord" value="<?php echo $article['ord'];?>">
            <span class="fi-help-text">数字越小越靠前,越大越靠后</span>
        </div>
    </div>
    -->
     
    <div class="formitems">
        <label class="fi-name">是否开启留言：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="need_guestbook" value="1" name="need_guestbook" <?php echo isset($article['need_guestbook']) && ($article['need_guestbook']) ? "checked" : (!isset($article['need_guestbook']) ? "checked":"");?>>开启</label>
                <label><input type="radio" class="need_guestbook" value="0" name="need_guestbook" <?php echo isset($article['need_guestbook']) && (!$article['need_guestbook']) ? "checked" : "";?>>关闭</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    <div class="formitems"  id="guestbook_tap" <?php if((isset($article['need_guestbook']) && !$article['need_guestbook'])){ ?> style="display:none;" <?php } ?>>
        <label class="fi-name"><span class="colorRed">*</span>留言提示：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" maxlength="10"  name="book_tips" value="<?php echo $article['book_tips']?$article['book_tips']:'联系我们:';?>">
            <span class="fi-help-text">显示在留言框上面</span>
        </div>
    </div>
    
<!--    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>是否仅会员阅读：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free" value="1" name="is_free" <?php echo isset($article['is_free']) && ($article['is_free']) ? "checked" : (!isset($article['is_free']) ? "checked":"");?>>所有人均可阅读</label>
                <label><input type="radio" class="is_free" value="0" name="is_free" <?php echo isset($article['is_free']) && (!$article['is_free']) ? "checked" : "";?>>仅会员</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    -->


    
<!--    <div class="formitems">
        <label class="fi-name">绑定商品id：</label>
        <div class="form-controls">
            <input type="text" class="input mini goods_id" maxlength="10"  name="goods_id" value="<?php echo $article['goods_id'];?>">
            <span class="fi-help-text">绑定商品id</span>
        </div>
    </div>-->
    
<!--    <div class="formitems" id="goods_tap" <?php if(!$article['goods_id']){ ?> style="display:none;" <?php } ?>>
        <label class="fi-name"><span class="colorRed">*</span>商品购买按钮文字：</label>
        <div class="form-controls">
            <input type="text" class="input xxlarge" maxlength="8"  name="buy_btn" value="<?php echo $article['buy_btn']?$article['buy_btn']:'立即购买';?>">
            <span class="fi-help-text">购买按钮的文字</span>
        </div>
    </div>-->

    
    
<!--    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>开启赞赏：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_zanshang" value="1" name="is_zanshang" <?php echo isset($article['is_zanshang']) && ($article['is_zanshang']) ? "checked" : "";?>>开启</label>
                <label><input type="radio" class="is_zanshang" value="0" name="is_zanshang" <?php echo isset($article['is_zanshang']) && (!$article['is_zanshang']) ? "checked" : (!isset($article['is_zanshang']) ? "checked":"");?>>关闭</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>-->
    

    
</div>



<div class="panel-single panel-single-light mgt20">
    <h3 class="cst_h3 mgb20">文章相册</h3>
    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>文章主图：</label>
	    <div class="form-controls pdt5 j-imglistPanel">

    <div id="uploadPic">
      <ul id="uploadlist" style=" height:90px; overflow:hidden;">
		<?php $sx=0;$p = json_decode($article['article_thumb'],true);foreach($p as $k=>$v){?>
	        <li>
	          <div class="displayimg">
	          <img src="<?php echo C("UPYUN_DOMAIN").$v;?>!w120" onerror="javascript:this.src='__STATIC__admin/images/error.png';" />
	          </div>
	          <a class="previous" href="javascript:void(0);"></a>
	          <span class="front-cover"><?php echo $sx==0 ? "封面":"";$sx++;?></span>
	          <a class="next" href="javascript:void(0);"></a>
	          <a class="delete" href="javascript:void(0);"></a>
	          <input type="hidden" name="article_thumb[]" id="article_thumb" value="<?php echo $v;?>" class="article_thumb" />
	        </li>
		<?php } ?>
      </ul>
      <div style="clear:both;"></div>
    </div>
	    <span class="btn btn-primary j-add"><span id="upload"></span></span>
	        <span class="fi-help-text">可以一次性选择多张图片上传,最对可以上传5张图片<br>建议图片尺寸为580px * 320px<br>注意:文章主图不同于文章详情图</span>
	    </div>
    </div>
    
    <div class="formitems">
        <label class="fi-name"><span class="colorRed">*</span>文章页显示主图：</label>
        <div class="form-controls">
            <div class="radio-group">
                <label><input type="radio" class="is_free_logistics" value="1" name="is_thumb" <?php echo isset($article['is_thumb']) && ($article['is_thumb']==1) ? "checked" : (!isset($article['is_thumb']) ? "checked":"");?>>显示</label>
                <label><input type="radio" class="is_free_logistics" value="0" name="is_thumb" <?php echo isset($article['is_thumb']) && ($article['is_thumb']==0) ? "checked" : "";?>>不显示</label>
            </div>
            <span class="fi-help-text"></span>
        </div>
    </div>
    
    
    <div class="formitems">
        <label class="fi-name">图片来源：</label>
        <div class="form-controls">
            <input type="text" class="input mini" maxlength="5" name="thumb_from" value="<?php echo $article['thumb_from'];?>">
            <span class="fi-help-text">如图片非原创,请注明来源</span>
        </div>
    </div>
    
    
    
    
    

    </div>

<!-- end 佣金设置 -->


<div class="panel-single panel-single-light mgt20 j-showinhyd">
    <h3 class="cst_h3 mgb20"></h3>
    
    <div class="formitems">
        <label class="fi-name">排序：</label>
        <div class="form-controls">
            <input type="text" class="input mini" name="ord" maxlength="5" value="<?php echo $article['ord']?$article['ord']:'500';?>">
            <span class="fi-help-text">排序,数字越大越靠后</span>
        </div>
    </div>
    
    

</div>
<!-- end 物流及其它 -->

<div class="panel-single panel-single-light mgt20 txtCenter">
	
	<?php if($action=="add"){?>
	
	
	
	<?php }else{?>
	
	<a href="javascript:weSubmit(1);" class="btn btn-primary j-add">保存</a>
	
	<?php }?>
	
	
	
    <a href="javascript:weSubmit(2);" class="btn btn-primary j-add">保存并去编辑文章详情</a>
    
</div>
</form>

</div>

<script type="text/javascript">
$(window).load(pageInit);
function pageInit(){
	
  var ext = '图片(*.gif;*.jpg;*.png;*.jpeg)';//默认值
  ext = ext.match(/([^\(]+?)\s*\(\s*([^\)]+?)\s*\)/i);
  
  swfu = new SWFUpload({
    flash_url : "/Static/admin/js/swfupload/swfupload.swf",
    prevent_swf_caching : false,//是否缓存SWF文件
    upload_url: '/admin/article/uploadpic', //上传文件路径
    file_post_name : "imgFile",
    post_params:  {'mychatpath':'article','imgcut':'1'},//随文件上传一同向上传接收程序提交的Post数据
    use_query_string : false,//是否用GET方式发送参数
    file_types : ext[2],//文件格式限制
    file_types_description : ext[1],//文件格式描述
    file_size_limit : '1MB',	//文件大小限制
    file_queue_limit:0,//上传队列总数
    file_upload_limit:5,//最多5张
    custom_settings : {
      test : "aaa"
    },
    file_queued_handler : fileQueued,//添加成功
    file_queue_error_handler : fileQueueError,//添加失败
    file_dialog_complete_handler : fileDialogComplete,
    upload_start_handler : uploadStart,//上传开始
    upload_progress_handler : uploadProgress,//上传进度
    upload_error_handler : uploadError,//上传失败
    upload_success_handler : uploadSuccess,//上传成功
    upload_complete_handler : uploadComplete,//上传结束
    button_placeholder_id : "upload",
    button_width: 80,
    button_height: 50,
    button_window_mode: SWFUpload.WINDOW_MODE.TRANSPARENT,
    button_cursor: SWFUpload.CURSOR.HAND,
    button_text : '<span class="redText">点击上传</span>',
    button_text_style: ".redText {color:#ffffff;}",
    button_text_left_padding: 10,
    button_text_top_padding: 5,
    debug: false
  });
}
</script>

<script type="text/javascript">
$(function(){
	
	$('#author_uid').change(function() {
		//判断当前账号是否正确
		var author_uid = $(this).val();
		//var tf_method = $('input[name="tf_method"]:checked ').val();
		
		if(author_uid==''){
			$("#teacher_tap").hide();
			return false;
		}

		ajaxUid(author_uid);
	});
});

function ajaxUid(author_uid){
	var url = "/admin/article/getfriend/?uid="+author_uid;
	
	$.ajax({
		url : url,
		type : "GET",
		dataType : 'json',
		success : function(data) {
			//关闭正在加载
			 layer.closeAll('loading');//关闭正在加载
			if(data.url){
				var urls = data.url;
			}else{
				var urls = '';
			}

			if(data.ret == 0){
				// 成功
				if(data.data.realname){
					var nickname = data.data.realname;
				}else{
					var nickname = data.data.nickname;
				}
				
				$("#headimgurl").attr("src",data.data.headimgurl);
				$("#author_headimgurl").val(data.data.headimgurl);
				$("#author_duty").val(data.data.duty);
				$("#author_desc").val(data.data.note);
				$("#author").val(nickname);
				
				$("#teacher_tap").show();
				
			}else{
				// 失败
				layer.msg(data.msg, {icon: 2});
			}
		},
		beforeSend:function(){
			//正在加载
			layer.load();//正在加载
       },
       error: function() {
		   //关闭正在加载
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
}



function weSubmit(go){

	$.ajax({
		url : '/admin/article/addarticle?article_id=<?php echo get("article_id");?>',
		type : "POST",
		data : $('#form').serialize(),
		dataType : 'json',
		async : false,
		success : function(data) {
			layer.closeAll('loading');//关闭正在加载
			if(data.ret == 0){
				// 成功
				var messagetype = 1;
			}else{
				// 失败
				var messagetype = 2;
			}
			if (data.url) {
				// 如果有跳转地址
				layer.msg(data.msg,{icon: messagetype}, function(){
					if(go==1){
						//不跳转
					}else{
						window.location.href = data.url;//跳转
					}
					
				}); 
				
			} else {
				layer.msg(data.msg, {icon: messagetype});
			}
		},
		beforeSend:function(){
			layer.load();//正在加载
       },
       error: function() {
		   layer.closeAll('loading');//关闭正在加载
		   layer.msg("网络错误,请重试", {icon: 2});
       }
       
	});
}


$(".goods_id").change(function() {
	var b = $("#goods_tap");
	
	if($(this).val()){
		b.show();
	}else{
		b.hide();
	}
});



$(".is_zanshang").change(function() {
	var b = $("#zanshang_tap");
	switch ($(this).val()) {
	case "1":
		b.show();
		break;
	case "0":
		b.hide();
		break;
	}
});


$(".need_guestbook").change(function() {
	var a = $("#guestbook_tap");
	switch ($(this).val()) {
	case "1":
		a.show();
		break;
	case "0":
		a.hide();
		break;
	}
});

$(".is_original").change(function() {
	var a = $(".j-feight-ipt");
	switch ($(this).val()) {
	case "1":
		a.attr("disabled", !0);
		break;
	case "0":
		a.attr("disabled", !1);
		break;
	}
});
</script>